/****************************************************************************
 *
 *                Admin Over IM
 *
 ****************************************************************************
 *
 *  <Copyright>
 *    Copyright (C) 2008  Basov Alexander
 *
 *  <Unit> iqfactory.cpp
 *   <ImplementationNotes>
 *   <PortabilityIssues>
 *   <AnticipatedChanges>
 *****************************************************************************
 *
 *  $Revision: 136 $ $Author: coopht $
 *  $Date: 2008-03-17 19:27:38 +0000 (Mon, 17 Mar 2008) $
 *****************************************************************************/

#include <cstring>
#include <iostream>
#include "iqfactory.h"

using namespace std;

IQ* IqFactory::create (const IQAttrs val)
{
  cout << "Create Called" << endl;
  cout << "TYPE = " << val.typeAttr << endl;
  cout << "QUERY = " << val.query << endl;

  if (val.typeAttr == "get")
  {
    if (val.query == "jabber:iq:version")    
      return dynamic_cast<IQ*>(new IQVersionRequest (val.idAttr, 
						     val.fromAttr,
						     val.toAttr));
    
    if (val.query == "http://jabber.org/protocol/disco#info")   
      return dynamic_cast<IQ*>(new IQServiceDiscoveryRequest (val.idAttr, 
							      val.fromAttr,	
							      val.toAttr));   
  return NULL;
      
  }
  else if (val.typeAttr == "set")
  {
    return NULL;
  }
  else if (val.typeAttr == "error")
  {
    return NULL;
  }
  else if (val.typeAttr == "result")
  {
    if (val.query == "")
      return dynamic_cast<IQ*>(new IQResult (val.idAttr, val.fromAttr));
    else 
      return NULL;
  }
}
